package com.carl.session;

import com.carl.config.RealConfiguration;
import com.carl.executor.Executor;
import com.carl.executor.impl.RealExecutor;
import com.carl.proxy.RealMapperProxy;

import java.lang.reflect.Proxy;

public class RealSqlSession {

    private Executor executor = new RealExecutor();

    private RealConfiguration configuration = new RealConfiguration();

    public <T> T selectOne(String statement,Object parameter){
        return executor.query(statement, parameter);
    }

    public <T> T getMapper(Class<T> clazz) {
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(),new Class[]{clazz},
                new RealMapperProxy(configuration,this));
    }

}
